package com.baseweb.webadmin.core.model.dao.impl;

import com.baseweb.webadmin.core.model.dao.RoleDao;
import com.baseweb.webadmin.core.model.pojo.Role;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.List;

public class RoleDaoImpl extends SqlSessionDaoSupport implements RoleDao {

    @Override
    public List<Role> selectRoleListByUser(String userId) {
        return this.getSqlSession().selectList("com.baseweb.webadmin.core.model.dao.RoleDao.selectRoleListByUser",userId);
    }

    @Override
    public List<Role> selectRoles() {
        return this.getSqlSession().selectList("com.baseweb.webadmin.core.model.dao.RoleDao.selectRoles");
    }


    @Override
    public Role selectRoleByName(Role role) {
        return (Role) this.getSqlSession().selectOne("com.baseweb.webadmin.core.model.dao.RoleDao.selectRoleByName", role);
    }

    @Override
    public List<Role> selectRolesByUser(Integer id) {
        return this.getSqlSession().selectList("com.baseweb.webadmin.core.model.dao.RoleDao.selectRolesByUser", id);
    }

    @Override
    public Role selectRoleByUserId(String userId) {
        return this.getSqlSession().selectOne("com.baseweb.webadmin.core.model.dao.RoleDao.selectRoleByUserId",userId);
    }
}
